<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>随便</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
  <script src="libs/handlebars.min.js"></script>
</head>
<body>
<div class="container">
		<div class="row">
			<div class="col-md-2">
					<ul class="nav nav-pills">
						<li class="active">
							<!--<a href="login.html">退出当前用户</a>  -->
							<button id="logout" class="btn btn-primary btn-block">退出当前用户</button>
						</li>
					</ul>
				</div>
			</div>
		</div>

 <div class="container">
   <div class="row">
    <div class="page-header">
     <h2 class="text-center"><strong>记账系统</strong></h2>  
    </div>
  </div>
</div>
<div class="container">
   <div class="row">
    <div class="col-md-8">
     <ul class="nav nav-pills">
      <li class="active"><a href="index.html">首页</a> </li>
      <li><a href="newpay.html">新加支出</a> </li>
      <li><a href="newin.html">新加收入</a> </li>
      <li><a href="tongji.html">统计</a> </li>
      <li><a href="query.html">查询</a> </li>
      
      <li><a href="#"><span id="nickname">用户</span></a></li>
     </ul>
    
 </div>
  </div>
</div>
<div class="container">
   <div class="row">
    <div class="col-md-12">
     <hr />  
    </div>
  </div>
</div>
<div class="container">
   <div class="row"> 
    <div class="col-md-6">
    <p>一周内的收入</p>
    <h4 id="text1"></h4>
    </div>
    <div class="col-md-6">
     <p>一周内的支出</p>
      <h4 id="text2"> </h4>
    </div>
   </div>
   <div class="row">
    <div class="col-md-12">
    <p>最近的四笔收入</p>
    <div id="list1"> </div>
     </div>
   </div>
    <div class="row">
    <div class="col-md-12">
    <p>最近的四笔支出</p>
    <div id="list2"></div>
     </div>
   </div>
</div>
<script type="text/x-handlebars-template" id="template" >
  {{#each item}}
     <div class="panel panel-default col-md-3">
       <div class="panel-body">
         <dl>
            <dt>时间</dt><dd>{{date_time}}</dd>
            <dt>地点</dt><dd>{{place}}</dd>
            <dt>金额</dt><dd>{{money_in}}</dd>
            <dt>类别</dt><dd>{{kind}}</dd>
        </dl>
      </div>
    </div>
  {{/each}}
{{#each item1}}
     <div class="panel panel-default col-md-3">
       <div class="panel-body">
         <dl>
            <dt>时间</dt><dd>{{date_time}}</dd>
            <dt>地点</dt><dd>{{place}}</dd>
            <dt>金额</dt><dd>{{money_out}}</dd>
            <dt>类别</dt><dd>{{remark}}</dd>
        </dl>
      </div>
    </div>
  {{/each}}
</script>

  


<script type="text/javascript" >
      $(function(){
	    $.getJSON('querymoney_out.action',function(res){
	    	console.log(res);
	    	$('#text2').text(res.s2);
	    	
	    });
	    $.getJSON('querymoney_in.action',function(res){
	    	console.log(res);
	    	$('#text1').text(res.s1);
	    	
	    });
	    
	    $.getJSON('queryuser.action',function(res){
	    	console.log(res);
	    	$('#nickname').text(res.s3);
	    	
	    });
	    
	    $.getJSON('queryshouru.action',function(res){
	    	console.log(res);
	    	var data ={'item':res};
	    	var t=Handlebars.compile($('#template').html());
	    	$('#list1').html(t(data));
	    });
	    
	    
	    $.getJSON('queryzhichu.action',function(res){
	    	console.log(res);
	    	var data ={'item1':res};
	    	var t=Handlebars.compile($('#template').html());
	    	$('#list2').html(t(data));
	    });
	    $('#logout').click(function () {
	        $.post('logout.action', {
	        
	       },function (res, status) {
	    	window.location.href="login.html";
	        });
	        
	    });
	 });
</script>
</body>
</html>